class TaskConfig {
  final int id;
  final String taskName;
  final String? resume;
  final String? taskReward;
  final double? startDate;
  final double? endDate;
  final String description;
  final String bannerUrl;
  final String? videos;
  final String status;
  final String? createTime;
  final String? updateTime;
  final int weight;
  final int isTrial;
  final String? playRule;
  final int? rewardLimit;
  final int? reportDurationMax;
  final String? jumpUrl;
  final List<String>? platformTypeList;
  final String taskType;
  final int? taskPeriod;
  final String? contentReward;
  final String? taskCode;
  final String? taskInstruction;
  final dynamic taskRecordBo;
  final dynamic productBoList;
  final List<dynamic> taskTagBoList;
  final List<dynamic> taskConfigMediaBoList;
  final List<String> images;

  TaskConfig({
    required this.id,
    required this.taskName,
    this.resume,
    this.taskReward,
    this.startDate,
    this.endDate,
    required this.description,
    required this.bannerUrl,
    this.videos,
    required this.status,
    this.createTime,
    this.updateTime,
    required this.weight,
    required this.isTrial,
    this.playRule,
    this.rewardLimit,
    this.reportDurationMax,
    this.jumpUrl,
    this.platformTypeList,
    required this.taskType,
    this.taskPeriod,
    this.contentReward,
    this.taskCode,
    this.taskInstruction,
    this.taskRecordBo,
    this.productBoList,
    required this.taskTagBoList,
    required this.taskConfigMediaBoList,
    required this.images,
  });

  factory TaskConfig.fromJson(Map<String, dynamic> json) {
    return TaskConfig(
      id: json['id'] ?? 0,
      taskName: json['taskName'] ?? '',
      resume: json['resume'],
      taskReward: json['taskReward'],
      startDate: json['startDate'] != null
          ? (json['startDate'] as num).toDouble()
          : null,
      endDate:
          json['endDate'] != null ? (json['endDate'] as num).toDouble() : null,
      description: json['description'] ?? '',
      bannerUrl: json['bannerUrl'] ?? '',
      videos: json['videos'],
      status: json['status'] ?? '',
      createTime: json['createTime']?.toString(),
      updateTime: json['updateTime']?.toString(),
      weight: json['weight'] ?? 0,
      isTrial: json['isTrial'] ?? 0,
      playRule: json['playRule'],
      rewardLimit: json['rewardLimit'] is int ? json['rewardLimit'] : null,
      reportDurationMax:
          json['reportDurationMax'] is int ? json['reportDurationMax'] : null,
      jumpUrl: json['jumpUrl'],
      platformTypeList: json['platformTypeList'] != null
          ? List<String>.from(json['platformTypeList'])
          : null,
      taskType: json['taskType'] ?? '',
      taskPeriod: json['taskPeriod'] is int ? json['taskPeriod'] : null,
      contentReward: json['contentReward'],
      taskCode: json['taskCode'],
      taskInstruction: json['taskInstruction'],
      taskRecordBo: json['taskRecordBo'],
      productBoList: json['productBoList'],
      taskTagBoList: List<dynamic>.from(json['taskTagBoList'] ?? []),
      taskConfigMediaBoList:
          List<dynamic>.from(json['taskConfigMediaBoList'] ?? []),
      images: List<String>.from(json['images'] ?? []),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'taskName': taskName,
      'resume': resume,
      'taskReward': taskReward,
      'startDate': startDate,
      'endDate': endDate,
      'description': description,
      'bannerUrl': bannerUrl,
      'videos': videos,
      'status': status,
      'createTime': createTime,
      'updateTime': updateTime,
      'weight': weight,
      'isTrial': isTrial,
      'playRule': playRule,
      'rewardLimit': rewardLimit,
      'reportDurationMax': reportDurationMax,
      'jumpUrl': jumpUrl,
      'platformTypeList': platformTypeList,
      'taskType': taskType,
      'taskPeriod': taskPeriod,
      'contentReward': contentReward,
      'taskCode': taskCode,
      'taskInstruction': taskInstruction,
      'taskRecordBo': taskRecordBo,
      'productBoList': productBoList,
      'taskTagBoList': taskTagBoList,
      'taskConfigMediaBoList': taskConfigMediaBoList,
      'images': images,
    };
  }
}
